home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 005 / epistat.arc / POISSON.BAS (.txt) < prev    next >
Encoding:
GW-BASIC  |  1983-10-18  |  1.6 KB  |  30 lines

  1. 1  REM              POISSON DISTRIBUTION (one-tailed)
  2. 2  REM             Written by Tracy L. Gustafson, M.D.
  3. 3  REM            Round Rock, Texas. Version 2.1, 1982
  4. 5  DEF SEG=&H40
  5. 6  A=PEEK(&H17): IF NOT(A AND &H20) THEN POKE &H17,(A AND (NOT &H20)) OR &H20
  6. 8  DEF SEG: KEY OFF: CLEAR: DEFINT A-C,N,T,Z: SCREEN 0,0: WIDTH 80: COLOR 7,0,1
  7. 10  CLS: PRINT TAB(22);"KEY";STRING$(34,205);"CLOSE"
  8. 12  PRINT TAB(22);"OPEN POISSON PROBABILITY DISTRIBUTION OPEN"
  9. 15  PRINT TAB(22);"SCREEN";STRING$(34,205);"LOAD": PRINT
  10. 20  PRINT " The Poisson distribution is a one-tailed exact test that applies specifically ": PRINT " when the number of SUCCESSES can be counted but the number of FAILURES cannot."
  11. 30  PRINT TAB(8);"It can also be used to approximate the binomial distribution": PRINT TAB(4);"when the number of trials is > 100 and the the population rate is < 5% ."
  12. 40  PRINT: PRINT : PRINT TAB(8);
  13. 50  INPUT "Enter the number of cases OBSERVED (integer):   ",NO: PRINT
  14. 60  PRINT TAB(8);"Enter the number of cases EXPECTED (may be fraction):": PRINT TAB(15);
  15. 70  PRINT "(e.g. population rate * time interval)": LOCATE 13,64: INPUT"", E
  16. 75  COLOR 23:PRINT:PRINT:PRINT:AP=CSRLIN:PRINT TAB(25);"CALCULATING PROBABILITY"
  17. 80  AF=0: CO=NO: CE=0: IF E<CO THEN CO=CO-1: AF=1
  18. 90  IF CO=0 THEN SF=1 ELSE SF=E+1
  19. 100  F=E: FOR Z=2 TO CO: F=F*E/Z: IF F>1E+22 THEN F=F*0: SF=SF* 0: CE=CE+1
  20. 110  IF F<0 THEN 120 ELSE SF=SF+F: NEXT Z
  21. 120  SL=LOG(SF)-E+CE*50: IF SL>80 THEN P=0 ELSE P=EXP(SL)
  22. 130  IF AF=1 THEN P=1-P
  23. 140  PLAY "MB O3 T120 L16 MS CCGE L6 C"
  24. 160  COLOR 0,7: LOCATE AP,1: PRINT TAB(8);"The probability of observing ";NO;" or ";
  25. 170  IF AF=1 THEN PRINT "more cases = "; ELSE PRINT "fewer cases = ";
  26. 190  IF P<9E-09 THEN PRINT "< 10 (-8)"; ELSE IF P>0.95 THEN PRINT "> .95"; ELSE PRINT P;
  27. 200  PRINT TAB(80): COLOR 7,0: PRINT: PRINT: PRINT: INPUT "Do you want to perform another Poisson distribution calculation? (Y or N)  ",A$
  28. 210  IF A$="y" OR A$="Y" THEN 10
  29. 220  END
  30.